package gui.funcionarios;

import gui.GerenciadorDeJanelas;

import java.awt.Dimension;
import java.awt.TextArea;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BorderFactory;
import javax.swing.JButton;

import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class DisciplinasEHorarios extends javax.swing.JPanel {
	private JLabel jLabel1;
	private TextArea mostraDisciplinas;
	private TextArea disciplinasDoProfessor;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JButton addRemoveHorario;
	private JButton removeDisciplina;
	private JButton addDisciplina;
	private JButton voltarBotao;
	

	/**
	* Auto-generated main method to display this 
	* 
	*/
	
	
	public DisciplinasEHorarios() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setPreferredSize(new Dimension(800, 600
					));
			this.setSize(800, 600);
			this.setLayout(null);
			this.setBackground(new java.awt.Color(204,204,255));
			{
				jLabel1 = new JLabel();
				this.add(jLabel1);
				jLabel1.setText("Disciplinas e Horarios do Professor");
				jLabel1.setFont(new java.awt.Font("Arial",0,36));
				jLabel1.setBounds(94, 5, 569, 44);
				jLabel1.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
				jLabel1.setForeground(new java.awt.Color(0,102,102));
			}
			{
				mostraDisciplinas = new TextArea();
				this.add(mostraDisciplinas);
				mostraDisciplinas.setText("jTextArea1");
				mostraDisciplinas.setBounds(56, 123, 208, 281);
				String saida = "";
				for(int i = 0; i < GerenciadorDeJanelas.todasDisciplinas.size(); i++){
					
					saida += GerenciadorDeJanelas.todasDisciplinas.get(i).toString() + "\n";
				}
				mostraDisciplinas.setEditable(true);
				mostraDisciplinas.setText(saida);
				mostraDisciplinas.setEditable(false);
				
			}
			{
				disciplinasDoProfessor = new TextArea();
				this.add(disciplinasDoProfessor);
				disciplinasDoProfessor.setBounds(481, 123, 227, 276);
				disciplinasDoProfessor.setEditable(false);
			}
			{
				jLabel2 = new JLabel();
				this.add(jLabel2);
				jLabel2.setText("Disciplinas cadastradas na Escola:");
				jLabel2.setBounds(73, 101, 182, 16);
			}
			{
				addDisciplina = new JButton();
				this.add(addDisciplina);
				addDisciplina.setText("Adiciona Disciplina");
				addDisciplina.setBounds(535, 426, 134, 23);
				addDisciplina.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
				addDisciplina.setBackground(new java.awt.Color(255,255,255));
				addDisciplina.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						String codigo = JOptionPane.showInputDialog("Digite o codigo da disciplina");
						for(int j = 0; j < GerenciadorDeJanelas.todasDisciplinas.size(); j++){
							if(GerenciadorDeJanelas.todasDisciplinas.get(j).getCodigo().equals(codigo)){
								try {
									SelecionaFuncionario.professor.addDisciplina(GerenciadorDeJanelas.todasDisciplinas.get(j));
									disciplinasDoProfessor.setEditable(true);
									String saida1 = "";
									saida1 = SelecionaFuncionario.professor.mostraDisciplinas();
									disciplinasDoProfessor.setText(saida1);
									JOptionPane.showMessageDialog(null, "Disciplina adicionada com sucesso");
									disciplinasDoProfessor.setEditable(false);
									return;
								} catch (Exception e) {
									JOptionPane.showMessageDialog(null, e.getMessage());
									e.printStackTrace();
								}
							}
						}JOptionPane.showMessageDialog(null, "Disciplina nao cadastrada na Escola");
					
					}
				});
			}
			{
				jLabel3 = new JLabel();
				this.add(jLabel3);
				jLabel3.setText("Disciplinas cadastradas na Escola:");
				jLabel3.setBounds(73, 101, 228, 16);
				jLabel3.setForeground(new java.awt.Color(0,102,102));
			}
			{
				jLabel4 = new JLabel();
				this.add(jLabel4);
				jLabel4.setText("Disciplinas Cadastradas para o Professor:");
				jLabel4.setBounds(488, 101, 264, 16);
				jLabel4.setForeground(new java.awt.Color(0,102,102));
			}
			{
				removeDisciplina = new JButton();
				this.add(removeDisciplina);
				removeDisciplina.setText("Remover Disciplina");
				removeDisciplina.setBounds(535, 454, 134, 23);
				removeDisciplina.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
				removeDisciplina.setBackground(new java.awt.Color(255,255,255));
				removeDisciplina.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						String codigo1 = JOptionPane.showInputDialog("Digite o codigo da disciplina a ser removida");
						for(int k = 0; k < GerenciadorDeJanelas.todasDisciplinas.size(); k++){
							try {
								if(GerenciadorDeJanelas.todasDisciplinas.get(k).getCodigo().equals(codigo1)){
									SelecionaFuncionario.professor.removeDisciplina(GerenciadorDeJanelas.todasDisciplinas.get(k));
									disciplinasDoProfessor.setEditable(true);
									disciplinasDoProfessor.setText(SelecionaFuncionario.professor.mostraDisciplinas());
									disciplinasDoProfessor.setEditable(false);
									JOptionPane.showMessageDialog(null, "Disciplina removida com sucesso");
									
								}
							} catch (Exception e) {
								JOptionPane.showMessageDialog(null, e.getMessage());
								e.printStackTrace();
							}
						}
					}
				});

			}
			{
				addRemoveHorario = new JButton();
				this.add(addRemoveHorario);
				addRemoveHorario.setText("Horarios");
				addRemoveHorario.setBounds(535, 482, 134, 23);
				addRemoveHorario.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
				addRemoveHorario.setBackground(new java.awt.Color(255,255,255));
				addRemoveHorario.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						HorarioPanel horarioPanel = new HorarioPanel();
						GerenciadorDeJanelas.window.setContentPane(horarioPanel);
						GerenciadorDeJanelas.window.setVisible(true);
					}
				});
			}
			{
				voltarBotao = new JButton();
				this.add(voltarBotao);
				voltarBotao.setText("Voltar");
				voltarBotao.setBounds(651, 528, 87, 32);
				voltarBotao.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
				voltarBotao.setBackground(new java.awt.Color(255,255,255));
				voltarBotao.addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						SelecionaFuncionario selecF = new SelecionaFuncionario();
						GerenciadorDeJanelas.window.setContentPane(selecF);
						GerenciadorDeJanelas.window.setVisible(true);
					}
				});
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
